#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
i=0
echo "${i}: "  `date +"%H:%M:%S"`
while [ 1 == 1 ]
do
    sleep 1m
    ping -c1 -W10 baidu.com &> /dev/null
    if [ "$?" != "0" ]; then
	nmcli device disconnect wlp9s0
	if [ "$?" == "0" ]; then
	    nmcli device connect wlp9s0
	    i=$((i+1))
	    echo "${i}: " `date +"%H:%M:%S"`
	fi
    fi
done
